package com.movie.playvideos.objects;

import java.io.Serializable;
import java.security.NoSuchAlgorithmException;

import android.sax.StartElementListener;
import android.util.Log;

import com.movie.playvideos.common.MD5;
import com.movie.playvideos.common.Setting;

public class MediaItemObject implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;
	private String name;
	private String des;
	private String playUrl;
	private String restUrl;
	private String secretCode;
	private String packageId;
	private String effectiveDate;
	private String remainingDate;
	private String packageImage;
	private String packageName;
	private String img;
	private String ttl;
	private String token;
	private String startTime;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
	public String getPlayUrl() {
		return playUrl;
	}
	public void setPlayUrl(String playUrl) {
		this.playUrl = playUrl;
	}
	public String getRestUrl() {
		return restUrl;
	}
	public void setRestUrl(String restUrl) {
		this.restUrl = restUrl;
	}
	public String getSecretCode() {
		return secretCode;
	}
	public void setSecretCode(String secretCode) {
		this.secretCode = secretCode;
	}
	public String getPackageId() {
		return packageId;
	}
	public void setPackageId(String packageId) {
		this.packageId = packageId;
	}
	public String getEffectiveDate() {
		return effectiveDate;
	}
	public void setEffectiveDate(String effectiveDate) {
		this.effectiveDate = effectiveDate;
	}
	public String getRemainingDate() {
		return remainingDate;
	}
	public void setRemainingDate(String remainingDate) {
		this.remainingDate = remainingDate;
	}
	public String getPackageImage() {
		return packageImage;
	}
	public void setPackageImage(String packageImage) {
		this.packageImage = packageImage;
	}
	public String getImg() {
		return img;
	}
	public void setImg(String img) {
		this.img = img;
	}
	public String getTtl() {
		return ttl;
	}
	public void setTtl(String ttl) {
		this.ttl = ttl;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getPackageName() {
		return packageName;
	}
	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}
	public String getPlayVideoUrl (){
		int timeStamp = (int) Math.floor(System.currentTimeMillis()/1000); 
		if(Setting.Debug)
			Log.e("Data: ", "packageId: " + packageId +", ttl: " + ttl + ", secretCode: " + secretCode);
		String md5Token = "";
		try {
			md5Token = MD5.hash(packageId + ":" + timeStamp + ":" + ttl + ":" + secretCode);
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String token = packageId + ":" + timeStamp + ":" + ttl + ":" + md5Token;
		String playUrl = this.playUrl + token + restUrl;
		return playUrl;
	}
}
